/* 
 *   Classname:  datapower.ExportToCSV
 * 
 *   Date       Developer   Description
 *   Nov 28, 2017    周成功              新建
 *
 */
package demo.database.mssql;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;

import javax.sql.DataSource;

import com.titan.core.utils.data.FormatUtils;
import com.titan.core.utils.db.DBUtils;
import com.titan.core.utils.db.DataSourceUtils;
import com.titan.core.utils.db.JdbcUtils;
import com.titan.core.utils.db.RecordSet;
import com.titan.core.utils.file.CSVUtils;
import com.titan.core.utils.file.ClassUtils;
import com.titan.core.utils.file.FileUtils;

/**
 *
 *
 * @author 周成功
 *
 */
public class ShowTables {
    private static String rootPath  = null;
    
    public static void main(String[] args) {
        Connection conn = null;
        try {
            String ip  = "192.168.128.213";
            String port  = "1433";
            String dbname  = "H20170913";
            String username = "sa";
            String password = "123456";
          
            conn = DBUtils.getMSSQLConnection(ip, port, dbname, username, password, true);
            
            run(conn);
        } catch(Exception ex) {
            ex.printStackTrace();
        } finally {
            DBUtils.close(conn);
        }
    }
    private static void run(Connection conn) throws Exception {
        String sql = "select name from sys.tables";
        String[] values = DBUtils.getValues(conn, sql, new String[0]);
        for (int i = 0; i < values.length; i++) {
            System.out.println(FormatUtils.to4Digit(i) + "\t" + values[i]);
        }
    }
}
